/* test_sha384.c
**
** Copyright (c) 2007, Meadhbh S. Hamrick
** All rights reserved.
** 
** Redistribution  and  use  in  source  and  binary  forms,  with  or  without
** modification, are permitted provided that the following conditions are met:
** 
**  * Redistributions of  source code must  retain the above  copyright notice,
**    this list of conditions and the following disclaimer.
** 
**  * Redistributions in binary form must reproduce the above copyright notice,
**    this list of conditions and the following disclaimer in the documentation
**    and/or other materials provided with the distribution.
** 
**  * Neither the  name of  Project Meadhbh  nor the names of  its contributors
**    may be used  to endorse  or promote  products derived from this  software
**    without specific prior written permission.
** 
** THIS SOFTWARE IS PROVIDED BY  THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY  EXPRESS OR IMPLIED WARRANTIES,  INCLUDING, BUT NOT  LIMITED TO, THE
** IMPLIED WARRANTIES  OF MERCHANTABILITY AND FITNESS FOR  A PARTICULAR PURPOSE
** ARE DISCLAIMED.  IN NO  EVENT SHALL THE  COPYRIGHT OWNER OR  CONTRIBUTORS BE
** LIABLE  FOR  ANY  DIRECT,   INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR
** CONSEQUENTIAL  DAMAGES  (INCLUDING,  BUT  NOT  LIMITED  TO,  PROCUREMENT  OF
** SUBSTITUTE GOODS  OR SERVICES;  LOSS OF USE,  DATA, OR PROFITS;  OR BUSINESS
** INTERRUPTION)  HOWEVER CAUSED  AND ON  ANY THEORY  OF LIABILITY,  WHETHER IN
** CONTRACT,  STRICT LIABILITY,  OR  TORT (INCLUDING  NEGLIGENCE OR  OTHERWISE)
** ARISING IN ANY WAY  OUT OF THE USE OF THIS SOFTWARE,  EVEN IF ADVISED OF THE
** POSSIBILITY OF SUCH DAMAGE.
** 
** $Id: test_sha384.c 53 2007-09-01 07:48:29Z msh.mobile $
*/

/** \file test_sha384.c
**  \brief Test SHA384 Cryptographic Hash Functions
**
** This   file   implements   the    tests   that   are   referenced   in
** test_crypto.c.   It  is  assumed   that  the   initalization  function
** suite_sha384_init()   will  be   called  before   any  of   the  test_*()
** functions. The initialization function does all the "heavy lifting" of
** creating  contexts  and hashing  test  vectors.  The individual  tests
** simply  compare output and  intermediate values  with known  good test
** values.
** 
** "Canonical"  test  vectors are  provided  in  the  inputs and  outputs
** arrays.   The inputs array  is an  array of  known strings  that, when
** hashed, are supposed to generate known values.  We're using the values
** from FIPS 180-2,  it's as close to authoratative as  we could find. To
** test the hashing functions, the suite_sha384_init() function hashes each
** string in the inputs array and places the result in the actual_outputs
** array.  In the  test_sha384_fips_vectors() function,  we  simply compare
** what  we generated  in the  actual_outputs array  with the  known good
** values in the outputs array.
** 
** Numerous  tests for cloning  behavior are  performed. Cloning  is used
** extensively in  these tests.  If it doesn't  work, then  it's unlikely
** that anything  will work. But we perform  a number of tests  to see if
** there are particular problems with cloning before or after various sha384
** function calls.
** 
** We test the mc_mic_sha384_clear() function by clearing a used context and
** then  comparing it  with a  newly initialized  context. Note  that the
** clear function  simply reinitializes a  context to it's  default state
** rather than zeroing memory.
** 
** The  mc_mic_sha384_initialize() function is  tested with  the known-value
** checks mentioned above. We also  verify that memory is properly zeroed
** out.
** 
** Finally,  the mc_mic_sha384_update()  function  is tested  by looking  at
** intermediate and final results in sha384 contexts.
*/

/* Macro Definitions */
#define MC_MIC_SHA384_TEST_MAX_CONTEXTS 11
#define MC_MIC_SHA384_TEST_MAX_VECTORS 3

/* File Includes */
#include <string.h>
#include "mutil.h"
#include "mcrypto/sha384.h"
#include "test_sha384.h"
#include <CUnit/CUnit.h>
#include <stdlib.h>
#include <stdio.h>

/* Typedefs, Structs, Unions, Enums, etc. */

/* Static Function Prototypes */

/* Variable Declarations */
tMCSha384 sha384_actual_contexts [ MC_MIC_SHA384_TEST_MAX_CONTEXTS ];
tMCSha384 sha384_contexts [ MC_MIC_SHA384_TEST_MAX_CONTEXTS ] = {
{
  .count = 0x0000000000000000LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000000LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000003LL,
  .data.asLongLong = {
    0x6162630000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000003LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCB00753F45A35E8BLL,
    0xB5A03D699AC65007LL,
    0x272C32AB0EDED163LL,
    0x1A8B605A43FF5BEDLL,
    0x8086072BA1E7CC23LL,
    0x58BAECA134C825A7LL,
    0xA303EDFDF3B89CD7LL,
    0x0C66918ECE57BA15LL
  }
},
{
  .count = 0x0000000000000070LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0x09330C33F71147E8LL,
    0x3D192FC782CD1B47LL,
    0x53111B173B3B05D2LL,
    0x2FA08086E3B0F712LL,
    0xFCC7C71A557E2DB9LL,
    0x66C3E9FA91746039LL,
    0x1E9F1F7449AD1749LL,
    0xFF334559A7135D3ALL
  }
},
{
  .count = 0x0000000000000010LL,
  .data.asLongLong = {
    0x6162636465666768LL,
    0x6263646566676869LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000070LL,
  .data.asLongLong = {
    0x6162636465666768LL,
    0x6263646566676869LL,
    0x636465666768696ALL,
    0x6465666768696A6BLL,
    0x65666768696A6B6CLL,
    0x666768696A6B6C6DLL,
    0x6768696A6B6C6D6ELL,
    0x68696A6B6C6D6E6FLL,
    0x696A6B6C6D6E6F70LL,
    0x6A6B6C6D6E6F7071LL,
    0x6B6C6D6E6F707172LL,
    0x6C6D6E6F70717273LL,
    0x6D6E6F7071727374LL,
    0x6E6F707172737475LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000070LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0x09330C33F71147E8LL,
    0x3D192FC782CD1B47LL,
    0x53111B173B3B05D2LL,
    0x2FA08086E3B0F712LL,
    0xFCC7C71A557E2DB9LL,
    0x66C3E9FA91746039LL,
    0x1E9F1F7449AD1749LL,
    0xFF334559A7135D3ALL
  }
},
{
  .count = 0x0000000000000000LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000000LL,
  .data.asLongLong = {
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
},
{
  .count = 0x0000000000000010LL,
  .data.asLongLong = {
    0x6162636465666768LL,
    0x6263646566676869LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL,
    0x0000000000000000LL
  },
  .state = {
    0xCBBB9D5DC1059ED8LL,
    0x629A292A367CD507LL,
    0x9159015A3070DD17LL,
    0x152FECD8F70E5939LL,
    0x67332667FFC00B31LL,
    0x8EB44A8768581511LL,
    0xDB0C2E0D64F98FA7LL,
    0x47B5481DBEFA4FA4LL
  }
}
};

uint8_t *sha384_inputs [ MC_MIC_SHA384_TEST_MAX_VECTORS ] = {
  (uint8_t *) "abc",   
  (uint8_t *) "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
  (uint8_t *) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
};

uint8_t sha384_actual_outputs [ MC_MIC_SHA384_TEST_MAX_VECTORS ][48];

uint8_t sha384_outputs [ MC_MIC_SHA384_TEST_MAX_VECTORS ][48] = {
    { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B, 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07, 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63, 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED, 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23, 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7 },
    { 0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8, 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47, 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2, 0x2F, 0xA0, 0x80, 0x86, 0xE3, 0xB0, 0xF7, 0x12, 0xFC, 0xC7, 0xC7, 0x1A, 0x55, 0x7E, 0x2D, 0xB9, 0x66, 0xC3, 0xE9, 0xFA, 0x91, 0x74, 0x60, 0x39 },
    { 0x9D, 0x0E, 0x18, 0x09, 0x71, 0x64, 0x74, 0xCB, 0x08, 0x6E, 0x83, 0x4E, 0x31, 0x0A, 0x4A, 0x1C, 0xED, 0x14, 0x9E, 0x9C, 0x00, 0xF2, 0x48, 0x52, 0x79, 0x72, 0xCE, 0xC5, 0x70, 0x4C, 0x2A, 0x5B, 0x07, 0xB8, 0xB3, 0xDC, 0x38, 0xEC, 0xC4, 0xEB, 0xAE, 0x97, 0xDD, 0xD8, 0x7F, 0x3D, 0x89, 0x85 }
};

/* Function Definitions */

/** \fn int suite_sha384_init( void )
**  \brief Calls various sha384 functions in preparation for value checking.
**  \returns 0 (success)
** 
** This is  the function where "rubber  meets the road." We  call all the
** functions  under test  in this  initialization function  and  in later
** tests simply compare the values we get with known good values.
** 
** We have  a series of tMCSha384  data structures used to  hold the hashing
** context after  various operations. This function  generally performs a
** function,  then clones  the context.  We do  this to  save information
** about the intermediate state of the hash functions. This can help with
** debugging if something  goes wrong. IT IS NOT  THE GENERAL PATTERN FOR
** USING THIS API.
** 
** The algorithm-specific  functions don't  return error codes  and don't
** check parameters. Ergo, we won't  know if there's a failure during the
** init routine's run. We get that info later in the test_*()
** functions.
*/

int suite_sha384_init() {
  uint32_t i;

  /* Initialize the first context */
  mc_mic_sha384_initialize( & (sha384_actual_contexts[0]) );

  /* Clone a context that has not been used */
  mc_mic_sha384_clone( & (sha384_actual_contexts[1]), & (sha384_actual_contexts[0]) ); 

  /* Clone a context for vector 0 */
  mc_mic_sha384_clone( & (sha384_actual_contexts[2]), & (sha384_actual_contexts[0]) );

  /* Hash "abc" (vector 0) */
  mc_mic_sha384_update( & (sha384_actual_contexts[2]), (uint8_t *) sha384_inputs[ 0 ], (uint32_t) strlen( (const char *) sha384_inputs[ 0 ] ) );

  /* Clone this context */
  mc_mic_sha384_clone( & (sha384_actual_contexts[3]), & (sha384_actual_contexts[2]) );

  /* Produce Digest for vector 0 */
  mc_mic_sha384_digest( & (sha384_actual_contexts[3]), (uint8_t *) sha384_actual_outputs[0] );

  /* Clone a context for vector 1 */
  mc_mic_sha384_clone( & (sha384_actual_contexts[4]), & (sha384_actual_contexts[0]) );

  /* Hash 16 bytes of "abcdefghijklmnopqrstuvwxyz" (vector 4) */
  mc_mic_sha384_update( & (sha384_actual_contexts[4]), (uint8_t *) sha384_inputs[1], 16 );

  /* Clone a context that has been updated with exactly 16 bytes, but not
     finalized */
  mc_mic_sha384_clone( & (sha384_actual_contexts[5]), & (sha384_actual_contexts[4]) );

  /* Clone it again so we have something to use */

  mc_mic_sha384_clone( & (sha384_actual_contexts[10]), & (sha384_actual_contexts[4]) );
  /* Hash the remainder of vector 1 */
  mc_mic_sha384_update( & (sha384_actual_contexts[4]), (uint8_t *) & (sha384_inputs[1][16]), (uint32_t) strlen( (const char *) &( sha384_inputs[1][16] ) ) );

  /* Clone a context that has been updated twice, but not finalized */
  mc_mic_sha384_clone( & (sha384_actual_contexts[6]), & (sha384_actual_contexts[4]) );

  /* Produce digest for vector 1 */
  mc_mic_sha384_digest( & (sha384_actual_contexts[4]), (uint8_t *) sha384_actual_outputs[1] );

  /* Clone a context that has been finalized */
  mc_mic_sha384_clone( & (sha384_actual_contexts[7]), & (sha384_actual_contexts[4]) );

  /* Clone a context for vector 2 */
  mc_mic_sha384_clone( & (sha384_actual_contexts[8]), & (sha384_actual_contexts[0]) );

  /* Hash one million "a" characters */
  for( i = 0; i < 10000; i++ ) {
    mc_mic_sha384_update( & (sha384_actual_contexts[8]), (uint8_t *) sha384_inputs[2], (uint32_t) strlen( (const char *) sha384_inputs[2] ) );
  }

  /* Produce digest for vector 2 */
  mc_mic_sha384_digest( & (sha384_actual_contexts[8]), (uint8_t *) sha384_actual_outputs[2] );

  /* Clear context 8 */
  mc_mic_sha384_clear( & (sha384_actual_contexts[8]) );

  /* Clone a context that's been cleared */
  mc_mic_sha384_clone( & (sha384_actual_contexts[9]), &(sha384_actual_contexts[8]) );

  return( 0 );
}

/** \fn void test_sha384_fips_vectors( void )
**  \brief Tests for compatibility with test vectors provided in FIPS 180-2
** 
** During the init function's run, we hashed a number of "canonical" test
** vectors listed in FIPS 180-2.  In this function, we simply compare the
** results  of our  computation (in  the actual_outputs  array)  with the
** known-good values given in the FIPS document (in the outputs array).
*/

void test_sha384_fips_vectors( ) {

  CU_ASSERT_EQUAL( 0, memcmp( sha384_outputs[0], sha384_actual_outputs[0], 48 ) );
  CU_ASSERT_EQUAL( 0, memcmp( sha384_outputs[1], sha384_actual_outputs[1], 48 ) );
  CU_ASSERT_EQUAL( 0, memcmp( sha384_outputs[2], sha384_actual_outputs[2], 48 ) );
}

/** \fn void test_mc_mic_sha384_clone( void )
**  \brief Tests our ability to clone hash contexts
** 
** In this  test, we  look to  see if our  ability to  copy a  context is
** dependent on  the state of the  context. I would be  very surprised if
** this fails.
*/

void test_mc_mic_sha384_clone( ) {
  /* Can we clone a newly initialized context? */
  CU_ASSERT_EQUAL( 0, memcmp( & (sha384_actual_contexts[0]), & (sha384_actual_contexts[1]), sizeof( tMCSha384 ) ) );

  /* Can we clone a context that's been updated with less than one block? */
  CU_ASSERT_EQUAL( 0, memcmp( & (sha384_actual_contexts[10]), & (sha384_actual_contexts[5]), sizeof( tMCSha384 ) ) );
  
  /* Can we clone a context that's been finalized? */
  CU_ASSERT_EQUAL( 0, memcmp( & (sha384_actual_contexts[4]), & (sha384_actual_contexts[7]), sizeof( tMCSha384 ) ) );

  /* Can we clone a context that's been cleared? */
  CU_ASSERT_EQUAL( 0, memcmp( & (sha384_actual_contexts[8]), & (sha384_actual_contexts[9]), sizeof( tMCSha384 ) ) );
}

/** \fn void test_mc_mic_sha384_clear( void )
**  \brief Tests to ensure that sensitive data is cleared
** 
** We test  the mc_mic_sha384_clear() function  by comparing the state  of a
** SHA384 context  after a  call to mc_mic_sha384_clear()  with the state  of a
** context  after a  call to  mc_mic_sha384_initialize(). If  they're equal,
** then we're good.
*/

void test_mc_mic_sha384_clear( ) {
  /* Compare context 0 (newly initialized) with context 8 (newly cleared) */
  CU_ASSERT_EQUAL( 0, memcmp( & (sha384_actual_contexts[0]), & (sha384_actual_contexts[8]), sizeof( tMCSha384 ) ) );
}

/** \fn void test_mc_mic_sha384_initialize( void )
**  \brief Tests the ability to initiailze a newly allocated hashing context. 
*/

void test_mc_mic_sha384_initialize( ) {
  /* Count should be zero */
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].count );

  /* Data values should be zero */
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 0] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 1] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 2] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 3] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 4] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 5] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 6] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 7] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 8] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[ 9] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[10] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[11] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[12] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[13] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[14] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[15] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[16] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[17] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[18] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[19] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[20] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[21] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[22] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[23] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[24] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[25] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[26] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[27] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[28] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[29] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[30] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[31] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[32] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[33] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[34] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[35] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[36] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[37] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[38] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[39] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[40] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[41] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[42] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[43] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[44] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[45] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[46] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[47] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[48] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[49] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[50] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[51] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[52] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[53] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[54] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[55] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[56] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[57] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[58] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[59] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[60] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[61] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[62] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[63] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[64] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[65] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[66] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[67] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[68] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[69] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[70] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[71] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[72] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[73] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[74] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[75] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[76] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[77] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[78] );
  CU_ASSERT_EQUAL( 0LL, sha384_actual_contexts[0].data.asLongLong[79] );

  /* State values are well known */
  CU_ASSERT_EQUAL( 0xCBBB9D5DC1059ED8LL, sha384_actual_contexts[0].state[0] );
  CU_ASSERT_EQUAL( 0x629A292A367CD507LL, sha384_actual_contexts[0].state[1] );
  CU_ASSERT_EQUAL( 0x9159015A3070DD17LL, sha384_actual_contexts[0].state[2] );
  CU_ASSERT_EQUAL( 0x152FECD8F70E5939LL, sha384_actual_contexts[0].state[3] );
  CU_ASSERT_EQUAL( 0x67332667FFC00B31LL, sha384_actual_contexts[0].state[4] );
  CU_ASSERT_EQUAL( 0x8EB44A8768581511LL, sha384_actual_contexts[0].state[5] );
  CU_ASSERT_EQUAL( 0xDB0C2E0D64F98FA7LL, sha384_actual_contexts[0].state[6] );
  CU_ASSERT_EQUAL( 0x47B5481DBEFA4FA4LL, sha384_actual_contexts[0].state[7] );
}

/** \fn void test_mc_mic_sha384_update( void )
**  \brief Tests the hash update function
** 
** Testing  the update  function is  fairly straight-forward.  We  have a
** series  of  known-good values  for  SHA384  contexts  at different  times
** throught the hashing  process. We simply compare the  test states with
** the known good values.
*/

void test_mc_mic_sha384_update( ) {

#ifndef WORDS_BIGENDIAN
  uint32_t j;

  for( j = 0; j < 8; j++ ) {
    sha384_actual_contexts[3].state[j] = MU_END64( sha384_actual_contexts[3].state[j] );
    sha384_actual_contexts[4].state[j] = MU_END64( sha384_actual_contexts[4].state[j] );
    sha384_actual_contexts[7].state[j] = MU_END64( sha384_actual_contexts[7].state[j] );
  }

  for( j = 0; j < 40; j++ ) {
    sha384_actual_contexts[2].data.asLongLong[j] = MU_END64( sha384_actual_contexts[2].data.asLongLong[j] );
    sha384_actual_contexts[5].data.asLongLong[j] = MU_END64( sha384_actual_contexts[5].data.asLongLong[j] );
    sha384_actual_contexts[6].data.asLongLong[j] = MU_END64( sha384_actual_contexts[6].data.asLongLong[j] );
    sha384_actual_contexts[10].data.asLongLong[j] = MU_END64( sha384_actual_contexts[10].data.asLongLong[j] );
  }
#endif

  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[0] ), (uint8_t *) &( sha384_contexts[0] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[1] ), (uint8_t *) &( sha384_contexts[1] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[2] ), (uint8_t *) &( sha384_contexts[2] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[3] ), (uint8_t *) &( sha384_contexts[3] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[4] ), (uint8_t *) &( sha384_contexts[4] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[5] ), (uint8_t *) &( sha384_contexts[5] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[6] ), (uint8_t *) &( sha384_contexts[6] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[7] ), (uint8_t *) &( sha384_contexts[7] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[8] ), (uint8_t *) &( sha384_contexts[8] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[9] ), (uint8_t *) &( sha384_contexts[9] ), sizeof( tMCSha384 ) ) );
  CU_ASSERT_EQUAL( 0, memcmp( (uint8_t *) &( sha384_actual_contexts[10] ), (uint8_t *) &( sha384_contexts[10] ), sizeof( tMCSha384 ) ) );
}
